﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeBehind="import.aspx.cs" Inherits="Maticsoft.Web.CERTI.import" Title="增加页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../js/ymPrompt.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
        #fullbg
        {
            background-color: Gray;
            display: none;
            z-index: 3;
            position: absolute;
            left: 0px;
            top: 0px;
            filter: Alpha(Opacity=30);
            -moz-opacity: 0.4;
            opacity: 0.4;
        }
        #dialog
        {
            position: absolute;
            width: 260px;
            height: 20px;
            background: #ccc;
            display: none;
            z-index: 50;
            font-size: 14px;
            font-weight: bold;
        }
        #main
        {
            height: 100%;
        }
    </style>

    <script type="text/javascript" src="../js/jquery-1.4.js"></script>

    <script src="../js/ymPrompt.js" type="text/javascript"></script>

<script>
    function noTitlebar(){};
    
    var tota=0;
   
    function checks()
    {
    
     if(confirm('您确定要导入吗？\r请确认字段的对应关系！'))
     {
     
     }else
     {
     }
     //return false;
    } 
   
    function procc()
    {
    tota=document.getElementById('ctl00_ContentPlaceHolder1_HiddenField2').value;
    ymPrompt.win({message:'<br /><br /><br /><br /><center><span id=\"spanabc\">正在导入请勿关闭！</span></center>',handler:noTitlebar,titleBar:false}); 
    //document.getElementById('ctl00_ContentPlaceHolder1_HiddenField2').innerHTML="正在导入请勿关闭！( "+to+" / "+tota+" )";
    //to++;
    setTimeout("procc2()",100);//定时调用
    }    
    var to=0;
     function procc2()
    {
    //ymPrompt.win({message:'<br /><br /><br /><br /><center><span id=\"spanabc\">正在导入请勿关闭！</span></center>',handler:noTitlebar,titleBar:false}); 
    document.getElementById('spanabc').innerHTML="正在导入请勿关闭！( "+to+" / "+tota+" )";
    to++;
    if(to<parseInt(tota))
    {
    setTimeout("procc2()",10);//定时调用
    }else
    {
    document.getElementById('spanabc').innerHTML="正在导入请勿关闭！( 正在检查数据的合法性 )";
    }
    
    }    
    
    function ajaxx1()
    {
    ymPrompt.win({message:'<br /><br /><br /><br /><center><span id=\"spanabc\">正在导入请勿关闭！</span></center>',handler:noTitlebar,titleBar:false}); 
    
    $.ajax({
type: "post",
url: "import.aspx",
data:{Name:"1"},
beforeSend: function(XMLHttpRequest){
//ShowLoading();
//alert(XMLHttpRequest.readyState);
//alert(XMLHttpRequest.status);
 
},
success: function(data, textStatus){
alert(data);
tota=data;
document.getElementById('spanabc').innerHTML=tota;
if(data=='1')
{
//setTimeout("ajaxx2()",100);//定时调用
}

},
complete: function(XMLHttpRequest, textStatus){
//alert('b');
//HideLoading();
},
error: function(){

//请求出错处理
}
});


}


var a=0;
function ajaxx2()
{
a++;
document.getElementById('div2').innerHTML=a;
    $.ajax({
type: "post",
url: "import.aspx",
data:{Name:"keyu"},
beforeSend: function(XMLHttpRequest){
//ShowLoading();
//alert(XMLHttpRequest.readyState);
//alert(XMLHttpRequest.status);
},
success: function(data, textStatus){
//alert(textStatus);
document.getElementById('spanabc').innerHTML=data;
if(data!='comp')
{
setTimeout("ajaxx2()",500);//定时调用
}

},
complete: function(XMLHttpRequest, textStatus){
//alert(textStatus);
//HideLoading();
},
error: function(){

//请求出错处理
}
});

}
    
    </script>
<fieldset style="display:none;">
    <legend style="font-weight:bold;">导入方式一（智能匹配，上传的Excel文件必须遵循如下格式）</legend>
<table style="width: 100%;" cellpadding="2" cellspacing="1" class="border">
        <tr>
            <td height="25" width="30%" align="right">
                请选择Excel文件 ：
            </td>
            <td height="25" width="*" align="left">
                <table>
                    <tr>
                        <td>
                            <asp:FileUpload ID="FileUpload1" runat="server" />
                            *.xls | *.xlsx
                        </td>
                        <td>
                            <td class="tdbg" align="center" valign="bottom">
                                <asp:Button ID="btnSave" runat="server" Text="导入" OnClientClick="javascript:function noTitlebar(){};ymPrompt.win({message:'<br /><br /><br /><br /><center>正在导入请勿关闭！</center>',handler:noTitlebar,titleBar:false});"
                    OnClick="btnSave_Click" class="inputbutton" onmouseover="this.className='inputbutton_hover'"
                    onmouseout="this.className='inputbutton'"></asp:Button>
                                <asp:Button ID="btnCancle" runat="server" Text="取消" OnClick="btnCancle_Click" class="inputbutton"
                                    onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'">
                                </asp:Button>
                            </td>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                导入结果 ：
            </td>
            <td height="25" width="*" align="left">
                <asp:Label ID="Label1" runat="server" Text="请选择文件"></asp:Label>
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                导入选项(是否覆盖现有数据) ：
            </td>
            <td height="25" width="*" align="left">
                <asp:RadioButton ID="RadioButton1" GroupName="imp" runat="server" Text="是" />
                <asp:RadioButton ID="RadioButton2" GroupName="imp" runat="server" Checked="true"
                    Text="否" />
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                温馨提示 ：
            </td>
            <td height="25" width="*" align="left">
                导入Excel文件格式必须遵循如下格式：
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td height="25" width="30%" align="right">
                &nbsp;
            </td>
            <td height="25" width="*" align="left">
                <img src="../Images/1.png" style="width: 600px; height:200px;" />
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                &nbsp;
            </td>
            <td height="25" width="*" align="left">
                <img src="../Images/2.png" style="height:200px;height:150px;" />
                <asp:HiddenField ID="HiddenField1" Value="" runat="server" />
                
            </td>
        </tr>
    </table>
</fieldset>

<fieldset>
    <legend style="font-weight:bold;">导入方式（手动匹配，首先上传Excel文件到服务器然后与必须遵循如下格式）</legend>
<table style="width: 100%;" cellpadding="2" cellspacing="1" class="border">
        <tr>
            <td height="25" width="30%" align="right">
                请选择Excel文件 ：
            </td>
            <td height="25" width="*" align="left">
                <table>
                    <tr>
                        <td>
                            <asp:FileUpload ID="FileUpload2" runat="server" />
                            *.xls | *.xlsx
                        </td>
                        <td>
                            <td class="tdbg" align="center" valign="bottom">
                                <asp:Button ID="Button1" runat="server" Text="上传" OnClientClick="javascript:function noTitlebar(){};ymPrompt.win({message:'<br /><br /><br /><br /><center>正在上传请稍后！</center>',handler:noTitlebar,titleBar:false});"
                    OnClick="btnBrower_Click" class="inputbutton" onmouseover="this.className='inputbutton_hover'"
                    onmouseout="this.className='inputbutton'"></asp:Button>
                                <asp:Button ID="Button2" runat="server" Text="取消" OnClick="btnCancle_Click" class="inputbutton"
                                    onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'">
                                </asp:Button>
                            </td>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                导入结果 ：
            </td>
            <td height="25" width="*" align="left">
                <asp:Label ID="Label2" runat="server" Text="尚未选择文件"></asp:Label>
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                导入选项(是否覆盖现有数据) ：
            </td>
            <td height="25" width="*" align="left">
                <asp:RadioButton ID="RadioButton3" GroupName="imp" runat="server" Text="是" />
                <asp:RadioButton ID="RadioButton4" GroupName="imp" runat="server" Checked="true"
                    Text="否" />
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
               请选择(对应字段) ：
            </td>
            <td height="25" width="*" align="left">
                &nbsp;
            </td>
        </tr>
        
        <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownList1" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 证书编号
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownList2" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 金成色
            </td>
        </tr>
        
         <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownListpm" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 品名
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownList3" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 净金重
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownList4" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 编码
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownList5" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 备注
            </td>
        </tr>
        <tr>
            <td height="25" width="30%" align="right">
                <asp:DropDownList ID="DropDownList6" runat="server">
                </asp:DropDownList> 
            </td>
            <td height="25" width="*" align="left">
                => 价格
            </td>
        </tr>
        
        <tr>
            <td height="25" width="30%" align="right">
                &nbsp;
                <asp:HiddenField ID="HiddenField2" runat="server" />
            </td>
            <td height="25" width="*" align="left">
                <asp:Button ID="Button3" runat="server" Text=" 导入 " OnClientClick="procc();" OnClick="btnSubmit_Click" class="inputbutton" style="display:" onmouseover="this.className='inputbutton_hover'"
                    onmouseout="this.className='inputbutton'"></asp:Button>
                    
            </td>
        </tr>
        
    </table>
    
</fieldset>
    
    <br />
    <%--<div id="main">
        <a href="#rhis" onclick="showBg('dialog','dialog_content');settime();">点击这里看JS遮罩层效果</a>
    </div>--%>
    <!-- JS遮罩层 -->
    <div id="fullbg">
    </div>
    <!-- end JS遮罩层 -->
    <!-- 对话框 -->
    <div id="dialog">
        <div id="dialog_content">
        </div>
        <%--<div style="text-align: center;"><a href="#" onclick="closeBg();">关闭</a></div>--%>
    </div>
    <!-- JS遮罩层上方的对话框 -->

    <script>
     var ids;    
    function settime()
    {
    //ids=window.setInterval(tip,100);
    }
    
    function tip(){
      //seed++;
      //document.getElementById('dialog_content').innerHTML=getCookie('comp');
      
      calls2();
      //alert(getCookie('comp'));
      //txt.value=seed/100;
}

 function getCookie(objName){//获取指定名称的cookie的值  
     var arrStr = document.cookie.split("; ");  
     for(var i = 0;i < arrStr.length;i ++){  
        var temp = arrStr[i].split("=");  
         if(temp[0] == objName) return unescape(temp[1]);  

    }   
 }  
 
 function calls2()
 {
 
 $.ajax({ url: "temp1.aspx", context: document.body, success: function(res){
        //$(this).addClass("done");
        document.getElementById('dialog_content').innerHTML=res;
      }});

 
 }
 
 function calls()
   {
  $.ajax
  ({
  url:"temp1.aspx",
  type:"post",
  cache:false,
  datatype:"html",
  //contenttype:"application/json; charset=utf-8",   
  //data:"{username:username,userpassword:userpass}",   
  //data:"username"=+username+&"userpassword"=+userpass+,  
  //data:"_username="+username+"&_userpassword="+userpass,   
  success:function(res)
  {
   document.getElementById('dialog_content').innerHTML=res;
  }
  
  })
  }
  
function getRootPath()
{
//return document.getElementById('ctl00_ContentPlaceHolder1_HiddenField1').value;
return "..";
}
//alert(getRootPath());

function getMessage(message) {
	loadFile();
	String.prototype.trim = function() {
		return this.replace(/(^\s*)|(\s*$)/g, "")
	}
	
	
	var nodes=xmlDoc.documentElement.childNodes; 
var now=new Date(); 
for(i=0;i<nodes.length;i++){ 
alert(nodes.item(i).childNodes.item(i).text);
}

for(i=0;i<nodes.length;i++){ 
alert(nodes.item(i).value);
}

for(i=0;i<nodes.length;i++){ 
alert(nodes.item(i).text);
}

//var value=nodes.item(i).childNodes.item(0).text ; 

	return xmlDoc.selectSingleNode("configuration/appSettings/add[@key='com']").getAttribute("value");
	
	return xmlDoc.selectSingleNode('configuration/appSettings/add[@key="com"]').getAttribute("value");
	
}
function loadFile() {
	//getLanguagekey();
	createDocumentObject();
	xmlDoc.load(getRootPath() + "/W.xml");
	
//	if (languagekey == "1") {
//		xmlDoc.load(getRootPath() + "/W.xml")
//	} else if (languagekey == "0") {
//		xmlDoc.load(getRootPath() + "/W.xml")
//	}

}
function createSelectSingleNodeAddSelectNodesMethod() {
	XMLDocument.prototype.selectSingleNode = Element.prototype.selectSingleNode = function(xpath) {
		var x = this.selectNodes(xpath);
		if(!x || x.length < 1)
		{return null;}
		return x[0]
	}
	XMLDocument.prototype.selectNodes = Element.prototype.selectNodes = function(xpath) {
		var xpe = new XPathEvaluator();
		var nsResolver = xpe.createNSResolver(this.ownerDocument == null ? this.documentElement: this.ownerDocument.documentElement);
		var result = xpe.evaluate(xpath, this, nsResolver, 0, null);
		var found = [];
		var res;
		while (res = result.iterateNext()) found.push(res);
		return found
	}
}
function createDocumentObject() {
	if ((xmlDoc == null) && window.ActiveXObject) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
	} else if (document.implementation && document.implementation.createDocument) {
		xmlDoc = document.implementation.createDocument("", "", null);
		createSelectSingleNodeAddSelectNodesMethod()
	}
	xmlDoc.async = false
}
function getLanguagekey() {
	var configDoc = null;
	if ((configDoc == null) && window.ActiveXObject) {
		configDoc = new ActiveXObject("Microsoft.XMLDOM")
	} else if (document.implementation && document.implementation.createDocument) {
		configDoc = document.implementation.createDocument("", "", null);
		createSelectSingleNodeAddSelectNodesMethod()
	}
	//configDoc.async = false;
	configDoc.load(getRootPath() + "/W.xml");
	var languagekeyNode = configDoc.selectSingleNode("configuration/add[@key='com']");
	languagekey = languagekeyNode.getAttribute("value")
}

//alert(getMessage("com"));

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

xmlDoc.async="false";
xmlDoc.load("../W.xml");
//nodes=xmlDoc.documentElement.childNodes
//var s=nodes.item(0).text
//var ss=nodes.item(1).text



    </script>

</asp:Content>
<%--<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceCheckright" runat="server">
</asp:Content>--%>
